// pages/category/category.js
import { getCategory } from "../api/index"
Page({
  data: {
    activeKey:0,
    categoryData:[],
    sliderData:[
        {
            "id":0,
            "text":"热门推荐"
        },
        {
            "id":1,
            "text":"手机数码"
        },
        {
            "id":2,
            "text":"家用电器"
        },
        {
            "id":3,
            "text":"电脑办公"
        },
        {
            "id":4,
            "text":"玩具乐器"
        },
        {
            "id":5,
            "text":"家具家装"
        },
        {
            "id":6,
            "text":"男装"
        },
        {
            "id":7,
            "text":"男鞋"
        },
        {
            "id":8,
            "text":"女装"
        },
        {
            "id":9,
            "text":"女鞋"
        },
        {
            "id":10,
            "text":"美妆护肤"
        },
        {
            "id":11,
            "text":"户外运动"
        }
    ],
    currentTag:"热门推荐",
  },
  onLoad(){
    this.http(this.data.currentTag)
  },
  clickItemNav(e){
    this.http(e.currentTarget.dataset.title)
  },
  clickItem(e){
    // console.log(e.currentTarget.dataset.tag)
    wx.navigateTo({
      url: '/pages/goods/goods?search=' + e.currentTarget.dataset.tag,
    })
  },
  http(tag){
    getCategory({tag}).then(res =>{
      if(res.data.status === 200){
        this.setData({
        categoryData:res.data.data
      })
      }else{
        wx.showToast({
          title: '暂无数据',
        })
        this.setData({
          categoryData:[]
        })
      }
    })
  },
  

})